unit fSelectMultiUser;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxLabel, cxControls, cxContainer, cxEdit, cxTextEdit,
  cxMaskEdit, cxDropDownEdit, cxCheckComboBox, Menus, cxLookAndFeelPainters,
  StdCtrls, cxButtons;

type
  TfmSelectMultiUser = class(TForm)
    cbxUser: TcxCheckComboBox;
    lblUser: TcxLabel;
    btnOk: TcxButton;
    btnCancel: TcxButton;
    procedure FormCreate(Sender: TObject);
    procedure btnOkClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    procedure SetCheckComboxPopup(Sql: string; Combox: TcxCheckComboBox);    
  public
    { Public declarations }
    UserIdList: TStringList;
  end;

var
  fmSelectMultiUser: TfmSelectMultiUser;

implementation

uses
  uPublic,tools,fClientDataModule;

{$R *.dfm}

procedure TfmSelectMultiUser.SetCheckComboxPopup(Sql: string; Combox: TcxCheckComboBox);
begin
  Combox.Properties.Items.Clear;
  try
    OpenPublicQuery(Sql);
    with ClientDataModule do
    begin
      tblDynamic.First;
      while not tblDynamic.EOF do
      begin
        Combox.Properties.Items.AddCheckItem(tblDynamic.Fields.Fields[0].AsString);
        UserIdList.Add(tblDynamic.Fields.Fields[1].AsString);
        tblDynamic.Next;
      end;
    end;
  finally
    ClosePublicQuery;
  end;
end; 

procedure TfmSelectMultiUser.btnOkClick(Sender: TObject);
begin
  if cbxUser.Text = '' then
  begin
    InfoDlg(Self.Caption +'!');
    Abort;
  end;
  ModalResult := mrOk;
end;

procedure TfmSelectMultiUser.FormCreate(Sender: TObject);
begin
  UserIdList := TStringList.Create;
  SetCheckComboxPopup('select bu_name,bu_id from b_user', cbxUser);
end;

procedure TfmSelectMultiUser.FormDestroy(Sender: TObject);
begin
  UserIdList.Free;
end;

end.
